#ifndef DATA_MANAGER_H_
#define DATA_MANAGER_H_
#include <mutex>
#include <thread>
#include <vector>

#include "common/data_scene.h"

struct DataManagerSettings {
  std::vector<std::string> data_scene_paths;
};

class DataManager final {
 public:
  DataManager(DataManager const&) = delete;
  DataManager& operator=(DataManager const&) = delete;
  DataManager(DataManager&&) = delete;
  DataManager& operator=(DataManager&&) = delete;
  ~DataManager();

  ///@brief Get instance
  ///@return service instance
  static DataManager& GetInstance() noexcept;

  ///@brief init
  ///@param settings DataManagerSettings
  void Init(DataManagerSettings const& settings) noexcept;

  ///@brief GetSettings
  ///@return DataManagerSettings
  DataManagerSettings GetSettings() const noexcept { return settings_; }

  ///@brief get data scene
  ///@return data scene
  DataScene& GetDataScene(uint16_t index) noexcept {
    return data_scenes_ptr_->at(index);
  }

  /// @brief
  /// @return
  int16_t GetDataSceneCount() noexcept {
    if (data_scenes_ptr_ != nullptr) {
      return data_scenes_ptr_->size();
    } else {
      return 0;
    }
  }

 protected:
  /// @brief constuctor
  DataManager() noexcept;

 private:
  ///@brief mutex , multi thread safe
  std::mutex mutex_;
  ///@brief init flag
  bool is_init_;
  ///@brief settings
  DataManagerSettings settings_;
  ///@brief data scene
  std::shared_ptr<std::vector<DataScene>> data_scenes_ptr_;
};

#endif  // !DATA_MANAGER_H_
